const variables = require('@mctech/mussel/src/variables.common')
const { resolve } = require('path')

module.exports = {

  browser: {
    alias: {
      entries: [
        { find: '@', replacement: resolve(__dirname, 'src/web-content') },
        {
          find: '@utils',
          replacement: resolve(__dirname, 'src/web-content/utils')
        }
      ]
    },
    vue: {
      css: false,
      config: {
        devtools: process.env.NODE_ENV === 'development'
      }
    },
    postcss: {
      variables
    },
    external: ['@mctech/trapa-workflow-client'],
    globals: {
      '@mctech/vue-kaka-grid': 'VueKakaGrid',
      '@mctech/trapa-workflow-client': 'workflowClient'
    }
  },
  sourcemap: true,
  clear: ['dist'],
  copy: {
    'src/server/bootstrap.yml': 'dist/bootstrap.yml',
    'src/server/individual.yml': 'dist/individual.yml',
    'node_modules/vue/dist': 'dist/web-content/lib/vue',
    'node_modules/vuex/dist': 'dist/web-content/lib/vuex',
    'node_modules/vue-router/dist': 'dist/web-content/lib/vue-router',
    'node_modules/axios/dist': 'dist/web-content/lib/axios',
    'node_modules/element-resize-detector/dist': 'dist/web-content/lib/element-resize-detector',
    'node_modules/@mctech/mussel/dist': 'dist/web-content/lib/mussel',
    'node_modules/@mctech/kaka-grid/dist': 'dist/web-content/lib/kaka-grid',
    'node_modules/@mctech/perfect-scrollbar/dist': 'dist/web-content/lib/perfect-scrollbar',
    'node_modules/@mctech/perfect-scrollbar/css': 'dist/web-content/lib/perfect-scrollbar',
    'node_modules/@mctech/vue-kaka-grid/dist': 'dist/web-content/lib/vue-kaka-grid',
    'node_modules/@mctech/web-frame/dist': 'dist/web-content/lib/web-frame',
    'node_modules/@mctech/trapa-workflow-client/dist': 'dist/web-content/lib/trapa-workflow-client',
    'node_modules/@mctech/infra-cloud/src/error/templates': 'dist/web-content/templates',
    'src/web-content/asset': 'dist/web-content/asset',
  },
  entries: {
    // 服务
    server: {
      alias: {
        entries: [
          {
            find: '@lib',
            replacement: resolve(__dirname, 'src/lib')
          }
        ]
      },
      input: 'src/server/index.js',
      output: 'dist/app.js'
    },
    test: {
      title: 'test',
      input: 'src/web-content/module/test/index.js',
      output: 'dist/web-content/asset/test.js'
    }
  }
}

